<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2018/12/5
 * Time: 11:16
 */

namespace app\sports_admin\model;


use think\Model;
use think\db;
use think\Request;

class TableBar extends Model
{
    protected $table = "table_bar";
    protected $pk    = "id";
    public function getIconPathAttr($values)
    {
        $data = "https://teacherxcx.tijian121.com/public".$values;
        return $data;
    }
    public function getContentAttr($content)
    {
        return htmlspecialchars_decode($content);
    }
    //找到子级视频的信息
    public static function bar($id)
    {
        return self::where('id',$id)->find();
    }
    //找到更新子级视频的信息
    public static function updateSection($request)
    {
        $data = Request::instance()->only(['id','zjtitle','content','icon_path','url']);
        $content = htmlspecialchars($data['content']);
        $id   = $data['id'];
        unset($data['id']);
        return self::where('id',$id)->update(['zjtitle'=>$data['zjtitle'],'content'=>$content,'icon_path'=>$data['icon_path'],'url'=>$data['url']]);
    }
    //添加子级视频
    public static function addVideo()
    {
        $data = Request::instance()->only(['cat_id','zjtitle','introduce','cat_id','video_path']);
        $content = htmlspecialchars($data['introduce']);
        return self::create(['catid'=>$data['cat_id'],'zjtitle'=>$data['zjtitle'],'content'=>$content,'url'=>$data['video_path']]);
    }
    //删除子级视频
    public static function delBarVideo($request)
    {
        $message = Request::instance()->only('id');
        return self::where('id',$message['id'])->delete();
    }


}